package com.example.exampleOS.util;

import ohos.agp.components.webengine.ResourceRequest;
import ohos.agp.components.webengine.WebAgent;
import ohos.agp.components.webengine.WebView;
import ohos.utils.net.Uri;

public class ExampleWebAgent extends WebAgent {
    public static final String EXAMPLE_URL = "https://www.baidu.com/index.php?tn=monline_3_dg";
    @Override
    public boolean isNeedLoadUrl(WebView webview, ResourceRequest request) {
        if (request == null || request.getRequestUrl() == null) {
            return false;
        }
        Uri uri = request.getRequestUrl();
        // EXAMPLE_URL由开发者自定义
        if (uri.getDecodedHost().equals(EXAMPLE_URL)) {
            // 增加开发者自定义逻辑
            return false;
        } else {
            return super.isNeedLoadUrl(webview, request);
        }
    }
}